﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.Linq;

namespace ATCAssistant
{
    public class Frequency
    {
        public Frequency(XElement comm)
        {
            this.Value = double.Parse(comm.Value);
            this.Callsign = comm.Attribute("callsign").Value;
            this.Position = this.CalculateType(comm);
        }

        public double Value { get; internal set; }
        public string Callsign { get; internal set; }
        public FrequencyType Position { get; internal set; }

        private FrequencyType CalculateType(XElement comm)
        {
            switch (comm.Attribute("position").Value.ToLower())
            {
                case "atis/awos/asos":
                    return FrequencyType.ATIS;
                case "clearance delivery":
                    return FrequencyType.ClearanceDelivery;
                case "ground":
                    return FrequencyType.Ground;
                case "tower":
                    return FrequencyType.Tower;
                case "approach":
                    return FrequencyType.Approach;
                case "departure":
                    return FrequencyType.Approach;
                case "center":
                    return FrequencyType.Center;
                case "flight service station":
                    return FrequencyType.FSS;
                default:
                    return FrequencyType.Other;
            }
        }
    }
}
